#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "cwds.h"
#include <QtDebug>
#include <QFileDialog>

#include <QGLWidget>
#include <QOpenGLFunctions>

class OpenGLWindow : public QGLWidget, protected QOpenGLFunctions
{
public:
    OpenGLWindow(QWidget *parent = nullptr);
protected:
    virtual void initializeGL( ) ;
    virtual void resizeGL (int nWidth, int nHeight);
    virtual void paintGL () ;

};

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public slots:
    void button_Next(); // Кнопка  >>

protected:
    void paintEvent(QPaintEvent *);
    virtual void mousePressEvent(QMouseEvent* mouse);
    virtual void mouseMoveEvent(QMouseEvent *mouse);

public:
    bool bwhs;
    CWhs whs;
    CWds wds;
    OpenGLWindow* pgl;
    bool openWds() { // RECLAMA.wds
        QString strFilter;
        QString str = QFileDialog::getOpenFileName(this, tr("Open File"), "/home/peter/d/Distribs/30SM_LS/WDS/", tr("WDS (*.wds);;WHS (*.whs)"), &strFilter);
        bwhs = false;
        if(!str.isEmpty()) {
            if(strFilter.contains("wds")) {
                if(wds.loadWds(str)) {
                    wds.dumpWds();
                    int k = str.lastIndexOf('/'); str.remove(0, k + 1);
                    setWindowTitle(str);
                    return true;
                }
            }
            if(strFilter.contains("whs")) {
                if(whs.loadWhs(str)) {
                    bwhs = true;
                    int k = str.lastIndexOf('/'); str.remove(0, k + 1);
                    setWindowTitle(str);
                    return true;
                }
            }
        }
        return false;
    }
};

#endif // MAINWINDOW_H
